import java.util.Scanner;

public class Strings_Are_Aqual {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n=scanner.nextInt();
        String[] aa = new String[n];
        String[] bb = new String[n];
        for(int i=0;i<n;i++){
            aa[i] = scanner.next();
            //scanner.nextLine();1
            bb[i] = scanner.next();
            //scanner.nextLine();
        }
        for(int i=0;i<n;i++){
            boolean s = istrue(aa[i],bb[i]);
            if(s) System.out.println("YES");
            else System.out.println("NO");
        }
    }
    public static boolean istrue(String a, String b){
        if(a.length() %2 ==1){
            return a.equals(b);
        }
        String al = a.substring(0,a.length()/2);
        String ar = a.substring(a.length()/2,a.length());
        String bl = a.substring(0,a.length()/2);
        String br = a.substring(a.length()/2,a.length());
        if( (al.equals(bl) && ar.equals(br)) || (al.equals(br) && (ar.equals(bl))) ){
            return true;
        }

        else{
            return (istrue(al,bl) && istrue(ar,br)) || (istrue(ar,bl) && istrue(al,br));
        }


    }
}
